﻿#ifndef QQ_CHAT_MESSAGEDELEGATE_H
#define QQ_CHAT_MESSAGEDELEGATE_H

#include <qicon.h>
#include <qpainter.h>
#include <qtextlayout.h>
#include <qpainterpath.h>
#include <qstyleditemdelegate.h>
#include <qtextdocument.h>
#include <qcache.h>
#include <qimagereader.h>
#include <qfileiconprovider.h>

#include "api/QQSystemApi.h"

#include "core/QQConfig.h"
#include "core/QQSettings.h"

class QQChatMessageDelegate : public QStyledItemDelegate
{
	Q_OBJECT
public:
	QQChatMessageDelegate(QObject* parent = nullptr);
	~QQChatMessageDelegate();

	void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
	QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;

private:
	const qreal mIconWidth{ 30 };
	const qreal mIconMarginLeftRight{ 10 };
	const qreal mNameMarginTopBottom{ 5 };
	const qreal mContentMargin{ 5 };
	const qreal mContentPadding{ 5 };
	const QSize mFileIconSize{ 64, 64 };
	const QSize mFileFrameSize{ 256, 96 };
	const QSize mPictureMaxSize{ 128,128 };
	mutable QCache<long, QTextDocument> mTextDocumentCache;
	QFileIconProvider mFileIconProvider;
};

#endif // QQ_CHAT_MESSAGEDELEGATE_H